import 'package:flame/events.dart';
import 'package:flame/game.dart';
import 'package:hero_back/study/flutter_game_flame/day003/circle.dart';

class CircleGame extends FlameGame with TapDetector, DoubleTapDetector {
  int counter = 0;

  @override
  Future<void> onLoad() async {

  }

  void addABall() {
    Circle circle = Circle(tag: "tag$counter");
    add(circle);
    counter++;
  }

  @override
  void onTap() {
    addABall();
  }

  @override
  void onDoubleTap() {
    List<Circle> circles = children.whereType<Circle>().toList();
    if (circles.isNotEmpty) {
      circles.first.removeFromParent();
    }
  }
}
